using System;

namespace BuffSystem
{
    [Serializable]
    public class CarrierComponent : FunctionComponent
    {
        protected string _occupantName;
        protected string _occupantKey;
        protected OccupantType _occupantType;
        public CarrierComponent(string occupantName, OccupantType occupantType)
        {
            _occupantName = occupantName;
            _occupantType = occupantType;
        }
        public CarrierComponent(string occupantName, string occupantType)
        {
            _occupantName = occupantName;
            _occupantType = (OccupantType)Enum.Parse(typeof(OccupantType), occupantType);
        }
        public CarrierComponent(string occupantName) { _occupantName = occupantName; }
        public override void RegisterPrepare(Buff buff, BuffManager owner, BuffManager target)
        {
            base.RegisterPrepare(buff, owner, target);
            _occupantKey = _occupantName + "." + _owner.name + "." + _target.name;
        }
        public override void Unregister()
        {
            if (_occupantType != OccupantType.Buff)
            {
                _target.Unregister(_occupantKey, _occupantType);
            }
        }
    }
}
